package org.liulinlin.sejw.db;

import java.sql.*;

public class LetterOfCredit { //extends DataAccessServiceImpl {
	private String id;
	private String bank;
	private java.sql.Date dateOfExpiry;
	private String dateOfExpiryString;
	private String contractID;
	private double amount;
	
	public LetterOfCredit() {
		
	}
	public LetterOfCredit(String id) {
		DBConnectionManager connMgr = DBConnectionManager.getInstance();
		Connection con = connMgr.getConnection("shipping_export");
		if (con == null) {
			System.out.println("不能获得数据库连接");
			return;
		}
		
		try {
			Statement stmt = con.createStatement();
			ResultSet rs = stmt.executeQuery("select * from LetterOfCredit where LOC_ID = '" + id + "'");
		
			rs.next();
			this.id = id;
			bank = rs.getString("LOC_Bank");
			dateOfExpiry = rs.getDate("LOC_DateOfExpiry");
			dateOfExpiryString = dateOfExpiry.toString();
			contractID = rs.getString("LOC_ContractID");
			amount = rs.getDouble("LOC_Amount");
			
			rs.close();
			stmt.close();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		
		connMgr.freeConnection("shipping_export", con);
		connMgr.release();
	}
	
	public void setId(String id) {
		this.id = id;
	}
	public void setBank(String bank) {
		this.bank = bank;
	}
	public void setDateOfExpiry(java.sql.Date dateOfExpiry) {
		this.dateOfExpiry = dateOfExpiry;
	}
	public void setDateOfExpiryString(String dateOfExpiryString) {
		this.dateOfExpiryString = dateOfExpiryString;
	}
	public void setContractID(String contractID) {
		this.contractID = contractID;
	}
	public void setAmount(double amount) {
		this.amount = amount;
	}
	
	public String getId() {
		return id;
	}
	public String getBank() {
		return bank;
	}
	public java.sql.Date getDateOfExpiry() {
		return dateOfExpiry;
	}
	public String getDateOfExpiryString() {
		return dateOfExpiryString;
	}
	public String getContractID() {
		return contractID;
	}
	public double getAmount() {
		return amount;
	}
}
